const state = {
  tags: [{
    title: '店铺概览',
    index: '/personalCenter/personInfo',
    icon: 'el-icon-tickets',
    active: true,
    closable: false
  }]
}
const mutations = {

  CHENGE_ACTIVE: (state, index) => {
    console.log("s")
    for (let i = 0; i < state.tags.length; i++) {
      state.tags[i].active = false
    }
    for (let i = 0; i < state.tags.length; i++) {
      if (state.tags[i].index === index) {
        state.tags[i].active = true
      }
    }
  },

  ADD_TAG: (state, tag) => {

    // for (let i = 0; i < state.tags.length; i++) {
    //   state.tags[i].active = false
    // }
    for (let i = 0; i < state.tags.length; i++) {
      if (state.tags[i].index === tag.index) {
        break;
      } else if (i === state.tags.length-1) {
        tag.active=true
        tag.closable=true
        state.tags.push(tag)
      }
    }

    // state.tags.push(tag)
  },
  REMOVE_TAG: (state, tag) => {
    state.tags.splice(state.tags.indexOf(tag), 1);
  }

}
const actions = {
  addTag({
      commit
    },
    tag) {
    return new Promise((resolve, reject) => {

    })
  },

  removeTag({
    commit
  }, tag) {

  }
}
export default {
  state,
  mutations,
  actions
}
